package main

import "container/list"

func findTheWinner(n int, k int) int {
	q := list.New()
	for i := 1; i <= n; i++ {
		q.PushBack(i)
	}
	for q.Len() > 1 {
		for i := 0; i < k-1; i++ {
			q.MoveToBack(q.Front())
		}
		q.Remove(q.Front())
	}
	return q.Front().Value.(int)
}
